/*
* Copyright 2011 Pavel Kozhin 
*
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed  under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*
* Author: Pavel Kozhin.
*/
package org.etherframework.core
{
	import mx.core.IMXMLObject;
	
	import org.etherframework.common.Access;
	import org.etherframework.common.DomainAccess;
	import org.etherframework.core.manager.EtherManager;
	import org.etherframework.dependency.Dependencies;
	import org.etherframework.mediator.Mediators;
	
	public class EtherConfig implements IMXMLObject
	{
		private var _id:String;
		private var _document:Object;
		private var _defaultAccess:String = Access.HIERARCHICAL;
		private var _defaultDomain:String = DomainAccess.SINGLE;

		public function initialized(document:Object, id:String):void
		{
			_document = document;
			_id = id;
			initializeModules();
			
			EtherManager.getInstance().initialize(this);
		}
		
		public function initializeModules():void
		{
			Dependencies.initialize();
			Mediators.initialize();
		}
		
		public function clone():EtherConfig
		{
			const generator:Class = this["constructor"] as Class;
			const result:EtherConfig = new generator();
			
			result.defaultAccess = defaultAccess;
			result.defaultDomain = defaultDomain;
			
			return result;
		}
		
		[Inspectable(defaultValue="hierarchical", enumeration="local,hierarchical,global")]
		public function get defaultAccess():String { return _defaultAccess; }
		public function set defaultAccess(value:String):void { _defaultAccess = value; }
		
		[Inspectable(defaultValue="single", enumeration="single,multiple")]
		public function get defaultDomain():String { return _defaultDomain; }
		public function set defaultDomain(value:String):void { _defaultDomain = value; }
	}
}